#include<iostream>
using namespace std;
char a[105][105];
char b[105][105];
int main()
{
    int n, m;
    cin >> n >> m;
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < m; j++)
        {
            cin >> a[i][j];
        }
    }
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < m; j++)
        {
            if (a[i][j] == '*')
            {
                b[i][j] = '*';
            }
            else
            {
                if (a[i][j - 1] == '*')b[i][j]++;
                if (a[i][j + 1] == '*')b[i][j]++;
                if (a[i - 1][j] == '*')b[i][j]++;
                if (a[i + 1][j+1] == '*')b[i][j]++;
                if (a[i - 1][j-1] == '*')b[i][j]++;
                if (a[i - 1][j+1] == '*')b[i][j]++;
                if (a[i + 1][j] == '*')b[i][j]++;
                if (a[i + 1][j-1] == '*')b[i][j]++;
            }
        }
    }
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < m; j++)
        {
            cout << b[i][j];
        }
        cout << endl;
    }
    return 0;
}